package com.wangrui.client.data;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceFloatField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;

public class FileNameXmlDS extends DataSource{
	
	public static FileNameXmlDS instance = null;  
	

	public static FileNameXmlDS getInstance(){
		
		if(instance == null){
			
			instance = new FileNameXmlDS("fileame");
		}
		
		return instance;
	}

	public FileNameXmlDS(String Id) {

		setID(id);   
        setTitleField("fileame");   
        setRecordXPath("/List/filename");   
        DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);   
  
        DataSourceIntegerField employeeIdField = new DataSourceIntegerField("EmployeeId", "Employee ID");   
        employeeIdField.setPrimaryKey(true);   
        employeeIdField.setRequired(true);   
  
        DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Manager");   
        reportsToField.setRequired(true);   
        reportsToField.setForeignKey(id + ".EmployeeId");   
        reportsToField.setRootValue("1");   
  
        DataSourceTextField jobField = new DataSourceTextField("Job", "Title", 128);   
        DataSourceTextField emailField = new DataSourceTextField("Email", "Email", 128);   
        DataSourceTextField statusField = new DataSourceTextField("EmployeeStatus", "Status", 40);   
        DataSourceFloatField salaryField = new DataSourceFloatField("Salary", "Salary");   
        DataSourceTextField orgField = new DataSourceTextField("OrgUnit", "Org Unit", 128);   
        DataSourceTextField genderField = new DataSourceTextField("Gender", "Gender", 7);   
        genderField.setValueMap("male", "female");   
        DataSourceTextField maritalStatusField = new DataSourceTextField("MaritalStatus", "Marital Status", 10);   
  
        setFields(nameField, employeeIdField, reportsToField, jobField, emailField,   
                statusField, salaryField, orgField, genderField, maritalStatusField);   
  
        setDataURL("ds/filename.ds.xml");   
        setClientOnly(true); 
	}

}
